<?php

	class Counter extends CI_Model
	{
		public function __construct()
		{
			parent::__construct();
		}

		public function increaseCounter()
		{
			$query = $this->db->get('tghm_counter');
			if($query->num_rows() > 0 && $query->num_rows() == 1)
			{
				$data = $query->row_array();
				$data['counter'] += 1;
				
				$this->db->where('id',$data['id']);
				$this->db->update('tghm_counter',$data);
			}
			else
			{
				$data['counter'] = 1;
				$this->db->insert('tghm_counter',$data);
			}
		}

		public function getCounter()
		{
			$query = $this->db->get('tghm_counter');
			return $query->row_array();
		}
	}